# Contributor: Nicolas Lorin <androw95220@gmail.com>
# Maintainer: Jonathan Sieber <mail@strfry.org>
pkgname=toxcore
pkgver=0.2.18
pkgrel=0
_cmpver=20
pkgdesc="Tox communication project - Core Library"
url="https://tox.chat/"
arch="all"
license="GPL-3.0-or-later"
makedepends="linux-headers cmake libsodium-dev opus-dev libvpx-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/TokTok/c-toxcore/archive/v$pkgver.tar.gz
	cmp-$_cmpver.tar.gz::https://github.com/camgunz/cmp/archive/refs/tags/v$_cmpver.tar.gz"

# Toxcore's tests do require networking and are not working properly in Travis-CI
options="!check"

builddir="$srcdir/c-$pkgname-$pkgver"

prepare() {
	mv ../cmp-$_cmpver/* third_party/cmp/
	default_prepare
}

build() {
	cmake . \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_LIBDIR=lib

	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	rm -f "$pkgdir"/usr/lib/*.a
}

sha512sums="
4bd8e90f395e7c8455b3e31bba0e72bb96a9fab2cbf0e3c2950a7f4b7fcaf8f250ef38fa30ba58a5a79d4cf2a4b5470e6c642597198bb7a7f711f28bbd13d65c  toxcore-0.2.18.tar.gz
f747cb9672592d8c06d08786152a0bfbd6ae4d759d7006805913781c502bf3796241ade636ce2cf9c049f68dd2899e2d5d7008815f29c1a91fc797590a26a9fd  cmp-20.tar.gz
"
